Openspeech Model¶
Openspeech Model¶
-
class
openspeech.models.openspeech_model.
OpenspeechModel
(configs: omegaconf.dictconfig.DictConfig, tokenizer: openspeech.tokenizers.tokenizer.Tokenizer)[source]¶ Super class of openspeech models.
Note
Do not use this class directly, use one of the sub classes.
- Parameters
configs (DictConfig) – configuration set.
tokenizer (Tokenizer) – tokenizer is in charge of preparing the inputs for a model.
- Inputs:
inputs (torch.FloatTensor): A input sequence passed to encoders. Typically for inputs this will be a padded FloatTensor of size
(batch, seq_length, dimension)
. input_lengths (torch.LongTensor): The length of input tensor.(batch)
- Returns
Result of model predictions.
- Return type
outputs (dict)
-
configure_criterion
(criterion_name: str) → torch.nn.modules.module.Module[source]¶ Configure criterion for training.
- Parameters
criterion_name (str) – name of criterion
- Returns
criterion for training
- Return type
criterion (nn.Module)
-
configure_optimizers
()[source]¶ Choose what optimizers and learning-rate schedulers to use in your optimization.
- Returns
Dictionary - The first item has multiple optimizers, and the second has multiple LR schedulers (or multiple
lr_dict
).
-
forward
(inputs: torch.FloatTensor, input_lengths: torch.LongTensor) → Dict[str, torch.Tensor][source]¶ Forward propagate a inputs and targets pair for inference.
- Inputs:
inputs (torch.FloatTensor): A input sequence passed to encoders. Typically for inputs this will be a padded FloatTensor of size
(batch, seq_length, dimension)
. input_lengths (torch.LongTensor): The length of input tensor.(batch)
- Returns
Result of model predictions.
- Return type
outputs (dict)
-
info
(dictionary: dict) → None[source]¶ Logging information from dictionary.
- Parameters
dictionary (dict) – dictionary contains information.
-
test_step
(batch: tuple, batch_idx: int)[source]¶ Forward propagate a inputs and targets pair for test.
- Inputs:
batch (tuple): A train batch contains inputs, targets, input_lengths, target_lengths batch_idx (int): The index of batch
- Returns
loss for training
- Return type
loss (torch.Tensor)
-
training_step
(batch: tuple, batch_idx: int)[source]¶ Forward propagate a inputs and targets pair for training.
- Inputs:
batch (tuple): A train batch contains inputs, targets, input_lengths, target_lengths batch_idx (int): The index of batch
- Returns
loss for training
- Return type
loss (torch.Tensor)
-
validation_step
(batch: tuple, batch_idx: int)[source]¶ Forward propagate a inputs and targets pair for validation.
- Inputs:
batch (tuple): A train batch contains inputs, targets, input_lengths, target_lengths batch_idx (int): The index of batch
- Returns
loss for training
- Return type
loss (torch.Tensor)